Skip to content

Conversation

@topheman
Copy link
Owner

This PR introduces the new plugin-tee plugin and makes necessary breaking changes to the WebAssembly Interface Types (WIT) contracts to enable enhanced plugin functionality.

🆕 New Features

plugin-tee

A new Rust-based plugin that implements the Unix tee command functionality:

  • File creation: Creates new files with content from the previous command output ($0)
  • File overwriting: Replaces existing file content
  • Append mode: Supports -a or --append flags to append content to existing files
  • Error handling: Provides detailed error messages for permission issues and file operations
  • Integration: Works seamlessly with other plugins like echo and cat in the REPL workflow

The plugin demonstrates the new plugin API capabilities by accessing REPL variables through the enhanced host interface.

⚠️ Breaking Changes

1. WIT Contract Changes (plugin-api.wit)

  • Added: host-state-plugin interface with get-repl-var function
  • Purpose: Allows plugins to access specific REPL variables by name (e.g., $0 for previous command output)
  • Impact: All existing plugins must be recompiled against the new WIT contracts

2. WIT Contract Changes (host-api.wit)

  • Removed: set-repl-var function from host-state interface
  • Reason: Functionality moved to plugin-specific interface for better separation of concerns
  • Impact: REPL logic components must be updated to use the new interface structure

🔧 Technical Implementation

  • Plugin Host: Enhanced with thread-safe REPL variable sharing using Arc<Mutex<T>>
  • WASM Integration: New bindings generated for all plugins to support the updated WIT contracts
  • Testing: Comprehensive test coverage for plugin-tee including file creation, overwriting, and append scenarios
  • Permissions: Plugin requires appropriate filesystem permissions (--allow-all for full functionality)

📋 Migration Guide

For Plugin Developers:

  1. Recompile plugins against the new WIT contracts
  2. Update any code that previously used set-repl-var to use the new plugin-specific interfaces
  3. Consider using the new get-repl-var function for accessing REPL state

For REPL Logic Components:

  1. Update to use the new WIT contract structure
  2. Ensure compatibility with the removed set-repl-var function

🧪 Testing

  • ✅ plugin-tee functionality (new file, overwrite, append)
  • ✅ Integration with existing plugins (echo, cat)
  • ✅ Error handling and permission management
  • ✅ WIT contract compatibility across all components

📚 Documentation

  • Added comprehensive README for plugin-tee
  • Updated WIT interface documentation
  • Enhanced test coverage demonstrating plugin capabilities

🌐 Web Version Note

The web version of plugin-tee is not part of this PR, it will be added in another one.

This release represents a significant step forward in plugin capabilities while maintaining the REPL's core functionality and security model.

topheman added 12 commits July 28, 2025 17:01
BREAKING CHANGE: break repl-logic backwards compatibility by changing
the wit contract
…gin can access a variable if they know the name

BREAKING CHANGE: break plugin-api backwards compatibility by changing
the wit contract
…WasiState and PluginHost

PluginHost needs to have access to repl_vars now that there is
plugin-api/host-state-plugin#get-repl-var in wit.

Use Arc<Mutex<T>> instead of direct references to satisfy Send trait
requirements for async WebAssembly operations. While the runtime is
single-threaded, Wasmtime's async bindings require Send + Sync types.
@topheman topheman self-assigned this Aug 16, 2025
@topheman topheman merged commit 87e46ae into master Aug 16, 2025
8 checks passed
@topheman topheman deleted the release-branch-pluginlab@0.5.0 branch August 17, 2025 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants